/**
  *@File文件:ImpShopBillService.java
  *@Date日期:2017年7月18日 上午8:51:51
  *@Copyright版权:Corporation 2017
  */
package com.qiaomengapp.serviceImp;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.qiaomengapp.bean.ShopBillWrapper;
import com.qiaomengapp.bean.ShopWarp;
import com.qiaomengapp.dao.ShopBillMapper;
import com.qiaomengapp.dao.ShopMapper;
import com.qiaomengapp.exception.CustomException;
import com.qiaomengapp.service.IShopBillService;

/**
 * @Description描述:
 * @Author作者 wangzongwen
 * @Date日期:2017年7月18日
 */
@Service
public class ImpShopBillService implements IShopBillService {
	// 操作商铺信息表
	@Autowired
	private ShopBillMapper shopBillMapper;
	
	//操作商铺表
	@Autowired
	private ShopMapper shopMapper;

	@Override
	public List<ShopBillWrapper> selectShopBillWrapper(int userId, Integer type) throws CustomException {
		//1、根据用户id的到对应商铺id
		ShopWarp shopWarp = shopMapper.select_shopByUid(userId);
		if (shopWarp==null) {
			throw new CustomException("该用户没有商铺！");
		}
		//2、查询商铺信息
		List<ShopBillWrapper> list = shopBillMapper.selectShopBillWrapper(shopWarp.getId(), type);		
		return list;
	}

	//查询商铺信息数量
	@Override
	public int selectShopBillCount(int uid) {
		//1、通过用户id 查询商铺id
		ShopWarp shopWarp = shopMapper.select_shopByUid(uid);
		//2、根据商铺id 查询商铺信息个数
		int count = shopBillMapper.selectShopBillCount(shopWarp.getId());
		return count;
	}

}
